import React from "react"

class TodoItem extends React.Component{
    constructor(props){
        super(props)
        this.handleItemClick = this.handleItemClick.bind(this)
    }
    //子组件如果向父组件通信，则子组件需要调用父组件传递过来的方法
    handleItemClick(){
        const { index } = this.props;
        this.props.delete(index);
    }


    render(){
        const {content} = this.props;
        return (
            <div onClick={this.handleItemClick} className = "task-item" >{content}</div>
        )
    }
}

export default TodoItem;